// 查询角色管理列表
export function listRoleApi(query: RoleRecord): Promise<ApiRowsRecord<RoleRecord[]>> {
  return request({
    url: `system/role/list`,
    method: 'get',
    params: query
  })
}

// 查询角色管理详细
export function getRoleApi(id: number): Promise<ApiDataRecord<RoleRecord>>  {
  return request({
    url: `system/role/${id}`,
    method: 'get'
  })
}

// 新增角色管理
export function addRoleApi(data: RoleRecord): Promise<ApiRecord> {
  return request({
    url: "system/role",
    method: 'post',
    data: data
  })
}

// 修改角色管理
export function updateRoleApi(data: RoleRecord): Promise<ApiRecord> {
  return request({
    url: "system/role",
    method: 'put',
    data: data
  })
}

// 删除角色管理
export function delRoleApi(id: number[]): Promise<ApiRecord> {
  return request({
    url: `system/role/${id}`,
    method: 'delete',
  })
}

// 角色状态修改
export function changeRoleStatusApi(data: RoleRecord): Promise<ApiRecord> {
  return request({
    url: '/system/role/changeStatus',
    method: 'put',
    data: data
  })
}

// 根据角色ID查询部门树结构
export function deptTreeSelectApi(roleId: number): Promise<ApiDataRecord<OptionRecord>> {
  return request({
    url: '/system/role/deptTree/' + roleId,
    method: 'get'
  })
}

// 角色数据权限
export function dataScopeApi(data: RoleRecord): Promise<ApiRecord> {
  return request({
    url: '/system/role/dataScope',
    method: 'put',
    data: data
  })
}

// 查询角色已授权用户列表
export function allocatedUserListApi(query: RoleAuthRecord): Promise<ApiDataRecord<UserRecord>> {
  return request({
    url: '/system/role/authUser/allocatedList',
    method: 'get',
    params: query
  })
}

// 查询角色未授权用户列表
export function unallocatedUserApi(query: RoleAuthRecord): Promise<ApiDataRecord<UserRecord>> {
  return request({
    url: '/system/role/authUser/unallocatedList',
    method: 'get',
    params: query
  })
}

// 取消用户授权角色
export function authUserCancelApi(data: RoleAuthRecord): Promise<ApiRecord> {
  return request({
    url: '/system/role/authUser/cancel',
    method: 'put',
    data: data
  })
}

// 批量取消用户授权角色
export function authUserCancelAllApi(data: RoleAuthRecord): Promise<ApiRecord> {
  return request({
    url: '/system/role/authUser/cancelAll',
    method: 'put',
    params: data
  })
}

// 授权用户选择
export function authUserSelectAllApi(data: RoleAuthRecord): Promise<ApiRecord> {
  return request({
    url: '/system/role/authUser/selectAll',
    method: 'put',
    params: data
  })
}

